<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['setting']=$this->plugin_setting('basic');
if($_RQ['op']=='main'){
	/*******main*******/
	//景点
	$id=$_RQ['id'];
	if(!$id){
		exi('该景点可能已下架或已删除','error');
	}
	$spot=pdo_get('jy_tour_spot',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	if($spot){
		$spot['images']=json_decode($spot['images'],true);
		$spot['sellnum']=pdo_count('jy_tour_order',array('uniacid'=>$_SESSION['uniacid'],'spot_id'=>$spot['id'],'status >'=>'0'));
		$pingjianum=pdo_count('jy_tour_assess',array('uniacid'=>$_SESSION['uniacid'],'spot_id'=>$spot['id']));
		$pinjia_good=pdo_count('jy_tour_assess',array('uniacid'=>$_SESSION['uniacid'],'spot_id'=>$spot['id'],'star >'=>'3'));
		$spot['manyidu']=$spot['sellnum']?ceil($pinjia_good/$spot['sellnum']*100):100;
		$spot['pingjianum']=$pingjianum;
		//查询门票
		$tickets=pdo_getall('jy_tour_spot_ticket',array('uniacid'=>$_SESSION['uniacid'],'spotid'=>$id));
		if($tickets){
			$merchs=array();
			foreach($tickets as &$ticket){
				$merch=pdo_get('jy_tour_merch',array('uniacid'=>$_SESSION['uniacid'],'id'=>$ticket['merchid']));
				$ticket['merch']=$merch;
				$spot_ticket=pdo_get('jy_tour_spot_ticket',array('uniacid'=>$_SESSION['uniacid'],'spotid'=>$id,'merchid'=>$merch['id']));
				
				$ticket['types']=json_decode($ticket['types'],true);
				//array_push($merchs,$merch);
			}
		}
		$first=	$tickets['0'];
		$first['suitfirst']=$first['types']['0'];

	}
	$return['merchs']=$merchs;
	$return['first']=$first;
	$return['spot']=$spot;
	$return['tickets']=$tickets;
	//print_r($spot['images']);exit;
	exi($return);
}
